import {
  createStore
} from 'vuex'
import axios from 'axios'
import persist from 'vuex-persistedstate'
export default createStore({
  state: {
    objList: [],
    searValue: '',
    isShow: 0,
  },
  mutations: {
    pushSearch(state, value) {
      let flag = false
      state.objList.forEach(element => {
        if (element.name == value) {
          flag = true
        }
      });
      if (!flag) {
        state.objList.unshift({
          name: value,
          id: new Date().getTime()
        })
      }
    },


    remove(state, value) {
      state.objList = state.objList.filter(item => item.id != value)
      console.log(value);
    },


    removeAll(state) {
      state.objList = []
    },

    fValue(state, value) {
      state.searValue = value.name
      console.log(value.name);
    },
    length(state, value) {
      console.log(value);
      state.isShow = value
    },
    ff(state) {
      state.isShow = false
    }


  },


  actions: {


  },
  plugins: [persist()]


})